package com.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.jdbc.core.RowMapper;

import com.common.uilt.TableTitle;
@Entity
@Table(name="tb_assets")
public class AssetsBean implements Serializable,Cloneable,RowMapper<AssetsBean>{

	/**
	 * 
	 */
	private static final long serialVersionUID = -2726542696571941323L;
	@Id
	@GenericGenerator(name = "idGenerator", strategy = "uuid")
	@GeneratedValue(generator = "idGenerator")
	private String id;
	@Column(nullable=false)
	@TableTitle(title="编号")
	private String a_number;		//编号 唯一
	@TableTitle(title="资产类别")
	private String a_class_name;	//资产类别
	@TableTitle(title="资产规格")
	private String a_specification;	//资产规格
	@TableTitle(title="资产名称")
	private String a_name;			//资产名称
	@TableTitle(title="计量单位")
	private String a_measure;		//单位
	@TableTitle(title="资产来源")
	private String a_source;		//来源
	@TableTitle(title="资产状态")
	private String a_status;		//资产状态
	@TableTitle(title="保管人员")
	private String a_custody_staff;	//保管人员
	@TableTitle(title="存放位置")
	private String a_store;			//存放位置
	
	//d 表示Depreciation（折旧）
	@Column(columnDefinition="number(10,2)")
	@TableTitle(title="资产单价")
	private Double a_unit_price;	//单价
	@TableTitle(title="使用年限")
	private Integer a_years;		//使用年限
	@Column(columnDefinition="number(10,2)")
	@TableTitle(title="净残率")
	private Double a_jc_rate;		//净残率
	@TableTitle(title="折旧方式")
	private String a_d_m;			//折旧方式
	@Column(columnDefinition="number(10,2)")
	@TableTitle(title="月提折旧")
	private Double a_ytd;			//月提折旧
	@Column(columnDefinition="number(10,2)")
	@TableTitle(title="累计折旧")
	private Double a_count_d;		//累计折旧
	@Column(columnDefinition="number(10,2)")
	@TableTitle(title="净值")
	private Double a_j_value;		//净值
	@TableTitle(title="购买日期")
	private String a_buy_date;		//购买日期
	@TableTitle(title="登记日期")
	private String a_register_data;	//登记日期
	@TableTitle(title="财务编码")
	private String a_f_number;		//财务编码
	@TableTitle(title="备注")
	private String a_remark;		//备注
	@TableTitle(title="机器序号")
	private String a_machine_no;	//机器序号
	private String a_img_src;
	
	@ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
    @JoinColumn(name="a_use_dept")//加入一列作为外键
	private DeptBean a_use_dept;  //使用部门
	
	@ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
    @JoinColumn(name="a_suppliers")//加入一列作为外键
	private SuppliersBean a_suppliers;
	//private String a_suppliers;		//供应商
	
	@OneToMany(fetch=FetchType.LAZY,cascade=CascadeType.ALL,mappedBy="assets_id")
	@Fetch(FetchMode.SELECT)
	private Set<AssetsDetailsBean> assetsdetails_list;
	
	/**
	 * 临时字段
	 * @return
	 */

	@Transient
	private String suppliers; //供应商字符串
	@Transient
	private String suppliers_id;
	@Transient
	private Integer number= new Integer(0);//数量
	public String getId() {
		return id;
	}
	/**
	 * id 唯一标识
	 * @return
	 */
	public void setId(String id) {
		this.id = id;
	}
	public String getA_number() {
		return a_number;
	}
	/**
	 * 编号 
	 * @return
	 */
	public void setA_number(String a_number) {
		this.a_number = a_number;
	}
	public String getA_class_name() {
		return a_class_name;
	}
	/**
	 * 资产类别 
	 * @return
	 */
	public void setA_class_name(String a_class_name) {
		this.a_class_name = a_class_name;
	}
	public String getA_specification() {
		return a_specification;
	}
	/**
	 * 规格
	 * @return
	 */
	public void setA_specification(String a_specification) {
		this.a_specification = a_specification;
	}
	public String getA_name() {
		return a_name;
	}
	/**
	 * 资产名称
	 * @return
	 */
	public void setA_name(String a_name) {
		this.a_name = a_name;
	}
	public String getA_measure() {
		return a_measure;
	}
	/**
	 * 计量单位 
	 * @return
	 */
	public void setA_measure(String a_measure) {
		this.a_measure = a_measure;
	}
	public String getA_source() {
		return a_source;
	}
	/**
	 *  来源
	 * @return
	 */
	public void setA_source(String a_source) {
		this.a_source = a_source;
	}
	public Double getA_unit_price() {
		return a_unit_price;
	}
	/**
	 * 单价 
	 * @return
	 */
	public void setA_unit_price(Double a_unit_price) {
		this.a_unit_price = a_unit_price;
	}
	public String getA_status() {
		return a_status;
	}
	/**
	 * 资产状态 
	 * @return
	 */
	public void setA_status(String a_status) {
		this.a_status = a_status;
	}
	public String getA_custody_staff() {
		return a_custody_staff;
	}
	/**
	 * 保管人员 
	 * @return
	 */
	public void setA_custody_staff(String a_custody_staff) {
		this.a_custody_staff = a_custody_staff;
	}
	public String getA_store() {
		return a_store;
	}/**
	 * 存放地点 
	 * @return
	 */
	public void setA_store(String a_store) {
		this.a_store = a_store;
	}
	public Integer getA_years() {
		return a_years;
	}/**
	 * 使用年限 
	 * @return
	 */
	public void setA_years(Integer a_years) {
		this.a_years = a_years;
	}
	public Double getA_jc_rate() {
		return a_jc_rate;
	}/**
	 * 净残率 
	 * @return
	 */
	public void setA_jc_rate(Double a_jc_rate) {
		this.a_jc_rate = a_jc_rate;
	}
	public String getA_d_m() {
		return a_d_m;
	}/**
	 * 折旧方式 
	 * @return
	 */
	public void setA_d_m(String a_d_m) {
		this.a_d_m = a_d_m;
	}
	public Double getA_ytd() {
		return a_ytd;
	}/**
	 * 月提折旧
	 * @return
	 */
	public void setA_ytd(Double a_ytd) {
		this.a_ytd = a_ytd;
	}
	public Double getA_count_d() {
		return a_count_d;
	}/**
	 * 累计折旧 
	 * @return
	 */
	public void setA_count_d(Double a_count_d) {
		this.a_count_d = a_count_d;
	}
	public Double getA_j_value() {
		return a_j_value;
	}/**
	 * 净值
	 * @return
	 */
	public void setA_j_value(Double a_j_value) {
		this.a_j_value = a_j_value;
	}
	public String getA_buy_date() {
		return a_buy_date;
	}/**
	 * 购买日期 
	 * @return
	 */
	public void setA_buy_date(String a_buy_date) {
		this.a_buy_date = a_buy_date;
	}
	public String getA_register_data() {
		return a_register_data;
	}/**
	 * 登记日期
	 * @return
	 */
	public void setA_register_data(String a_register_data) {
		this.a_register_data = a_register_data;
	}
	public String getA_f_number() {
		return a_f_number;
	}/**
	 *  财务编码
	 * @return
	 */
	public void setA_f_number(String a_f_number) {
		this.a_f_number = a_f_number;
	}
	public String getA_remark() {
		return a_remark;
	}/**
	 * 备注
	 * @return
	 */
	public void setA_remark(String a_remark) {
		this.a_remark = a_remark;
	}
	public String getA_machine_no() {
		return a_machine_no;
	}/**
	 * 机器序列号 
	 * @return
	 */
	public void setA_machine_no(String a_machine_no) {
		this.a_machine_no = a_machine_no;
	}
	public String getA_img_src() {
		return a_img_src;
	}/**
	 * 图片信息 
	 * @return
	 */
	public void setA_img_src(String a_img_src) {
		this.a_img_src = a_img_src;
	}
	public DeptBean getA_use_dept() {
		return a_use_dept;
	}
	public void setA_use_dept(DeptBean a_use_dept) {
		this.a_use_dept = a_use_dept;
	}
	public SuppliersBean getA_suppliers() {
		return a_suppliers;
	}
	public void setA_suppliers(SuppliersBean a_suppliers) {
		this.a_suppliers = a_suppliers;
	}
	public String getSuppliers() {
		return suppliers;
	}
	public void setSuppliers(String suppliers) {
		this.suppliers = suppliers;
	}
	public String getSuppliers_id() {
		return suppliers_id;
	}
	public void setSuppliers_id(String suppliers_id) {
		this.suppliers_id = suppliers_id;
	}
	public Integer getNumber() {
		return number;
	}
	public void setNumber(Integer number) {
		if(number<1)
			this.number=1;
		else
			this.number = number;
	}
	public Set<AssetsDetailsBean> getAssetsdetails_list() {
		return assetsdetails_list;
	}
	public void setAssetsdetails_list(Set<AssetsDetailsBean> assetsdetails_list) {
		this.assetsdetails_list = assetsdetails_list;
	}
	@Override
	public Object clone() throws CloneNotSupportedException {
		// TODO Auto-generated method stub
		return super.clone();
	}
	public static void main(String[] args) {
		DecimalFormat myformat = new DecimalFormat();
		myformat.applyPattern("##,###");
		System.out.println(myformat.format(11112345.12345));
		BigDecimal numberOfMoney = new BigDecimal(myformat.format(11112345.12345));
		System.out.println(numberOfMoney);
	}
	@Override
	public AssetsBean mapRow(ResultSet rs, int rowNum) throws SQLException {
		
		return null;
	}
//	@Override
//	public int hashCode() {
//		final int prime = 31;
//		int result = 1;
//		result = prime * result
//				+ ((a_class_name == null) ? 0 : a_class_name.hashCode());
//		result = prime * result
//				+ ((a_measure == null) ? 0 : a_measure.hashCode());
//		result = prime * result + ((a_name == null) ? 0 : a_name.hashCode());
//		result = prime * result
//				+ ((a_status == null) ? 0 : a_status.hashCode());
//		result = prime * result
//				+ ((a_unit_price == null) ? 0 : a_unit_price.hashCode());
//		return result;
//	}
//	@Override
//	public boolean equals(Object obj) {
//		if (this == obj)
//			return true;
//		if (obj == null)
//			return false;
//		if (getClass() != obj.getClass())
//			return false;
//		AssetsBean other = (AssetsBean) obj;
//		if (a_class_name == null) {
//			if (other.a_class_name != null)
//				return false;
//		} else if (!a_class_name.equals(other.a_class_name))
//			return false;
//		if (a_measure == null) {
//			if (other.a_measure != null)
//				return false;
//		} else if (!a_measure.equals(other.a_measure))
//			return false;
//		if (a_name == null) {
//			if (other.a_name != null)
//				return false;
//		} else if (!a_name.equals(other.a_name))
//			return false;
//		if (a_status == null) {
//			if (other.a_status != null)
//				return false;
//		} else if (!a_status.equals(other.a_status))
//			return false;
//		if (a_unit_price == null) {
//			if (other.a_unit_price != null)
//				return false;
//		} else if (!a_unit_price.equals(other.a_unit_price))
//			return false;
//		System.out.println(this.number+++"次");
//		return true;
//	}
}
